# Makefile for building and installing lua-cjson-53

# Variables
CC = gcc
CFLAGS = -fPIC -I/usr/include/lua5.3
LDFLAGS = -shared -lm
TARGET = cjson.so
SRC_DIR = src
SRC = $(SRC_DIR)/fpconv.c $(SRC_DIR)/strbuf.c $(SRC_DIR)/lua_cjson.c
TARGET_DIR = /usr/local/lib/lua/5.3

# Default target
all:clean $(TARGET)

# Build target
$(TARGET): $(SRC)
	$(CC) $(CFLAGS)  $(SRC) -o $(TARGET) $(LDFLAGS)

# Install target
install: $(TARGET)
	mkdir -p $(DESTDIR)$(TARGET_DIR)
	cp $(TARGET) $(DESTDIR)$(TARGET_DIR)

# Clean target
clean:
	rm -f $(TARGET)

# Phony targets
.PHONY: all install clean
